<template>
  <div>
    <!-- <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>商品管理</el-breadcrumb-item>
      <el-breadcrumb-item>商品列表</el-breadcrumb-item>
    </el-breadcrumb> -->
    <el-card class="box-card">
      <el-input placeholder="请输入商品名称" clearable v-model="search">
        <el-button slot="append" icon="el-icon-search"></el-button>
      </el-input>
      <el-button type="primary">添加商品</el-button>
      <el-table :data="goods"  border style="width: 100%" stripe>
        <el-table-column type="index"  label="序号" width="80">
        </el-table-column>
        <el-table-column prop="goods_name" label="商品名称" >
        </el-table-column>
        <el-table-column prop="goods_price" label="商品价格(元)"> </el-table-column>
        <el-table-column prop="goods_weight" label="商品重量" >
        </el-table-column>
        <el-table-column prop="add_time" label="创建时间" >
        </el-table-column>
        <el-table-column prop="address" label="操作" width="150">
          <el-button type="primary" icon="el-icon-edit" size="mini"></el-button>
          <el-button type="danger"  icon="el-icon-delete" size="mini"></el-button>
        </el-table-column>
      </el-table>
  <div class="block">
    <!-- <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="params.pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination> -->
  </div>
    </el-card>
<!-- 修改角色 -->
    <!-- <el-dialog title="修改角色" :visible.sync="dialogModifyRoles">
            <el-form ref="modifyform" :model="modifyRoles" :rules="$rules.user" >
                <el-form-item label="角色名称" :label-width="formLabelWidth" prop="roleName">
                    <el-input v-model="modifyRoles.roleName" autocomplete="off"  ></el-input>
                </el-form-item>
                <el-form-item label="角色描述" :label-width="formLabelWidth" prop="roleDesc">
                    <el-input v-model="modifyRoles.roleDesc" autocomplete="off" ></el-input>
                </el-form-item>
            </el-form>
            <template v-slot:footer class="dialog-footer">
                <el-button @click="dialogModifyRoles = false">取 消</el-button>
                <el-button type="primary" @click="ModifyRoles()">确 定</el-button>
            </template>
      </el-dialog> -->
  </div>
</template>
<script>
export default {
  data() {
    return {
      total:null,
      search: "",
      params:{
        pagenum:1,
        query:'',
        pagesize:10,
      },
      goods:[],
      formLabelWidth:"120px",
      dialogModifyRoles:false,
    }
  },
  methods: {
      handleSizeChange(val) {
        this.params.pagesize=val
        this.LoadGoods();
      },
      handleCurrentChange(val) {
        this.params.pagenum=val
        this.LoadGoods();
      },
    async  LoadGoods(){
        try {
        let result= await this.$api.getGoods(this.params);
        console.log(result)
        this.goods=result.goods;
        this.total=result.total;
        this.params.pagenum=result.pagenum
        console.log(this.goods)
        } catch (error) {
            console.log(error)
        }
      }
  },
  created() {
      this.LoadGoods();
  },
};
</script>
<style lang="less" scoped>
.el-breadcrumb {
  margin-bottom: 20px;
}
.el-input {
  margin-bottom: 10px;
  width: 400px;
  margin-right: 20px;
}
.block{
    margin-top: 50px;
}
</style>